This is long overdue to make it to libgsystem. Update our dependency.
PKG_PROG_PKG_CONFIG
-GIO_DEPENDENCY="gio-unix-2.0 >= 2.36.0 libgsystem >= 2014.2"
+GIO_DEPENDENCY="gio-unix-2.0 >= 2.36.0 libgsystem >= 2014.3"
PKG_CHECK_MODULES(OT_DEP_GIO_UNIX, $GIO_DEPENDENCY)
dnl 5.1.0 is an arbitrary version here
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
{
if (errno != EEXIST)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fsync (fd) == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
AT_SYMLINK_NOFOLLOW) == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (fd == -1 && errno == EINTR));
if (fd == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
temp_out = g_unix_output_stream_new (fd, TRUE);
if (G_UNLIKELY (renameat (destination_dfd, temp_filename,
destination_dfd, destination_name) == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
else
{
g_prefix_error (error, "Hardlinking %s to %s: ", loose_path, destination_name);
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
did_exist = TRUE;
else
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
{
if (fsync (destination_dfd) == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
int errsv = errno;
if (G_UNLIKELY (errsv != EEXIST))
{
- ot_util_set_error_from_errno (error, errsv);
+ gs_set_error_from_errno (error, errsv);
return FALSE;
}
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
return FALSE;
}
self->target_owner_gid,
AT_SYMLINK_NOFOLLOW) == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
AT_SYMLINK_NOFOLLOW) == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
{
if (fsync (fd) == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
{
if (errno != EEXIST)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out;
}
int r = posix_fallocate (fd, 0, size);
if (r != 0)
{
- ot_util_set_error_from_errno (error, r);
+ gs_set_error_from_errno (error, r);
goto out;
}
}
if (fstat (self->objects_dir_fd, &stbuf) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
d = fdopendir (dfd);
if (!d)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
continue;
else
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
ret = TRUE;
goto out;
}
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
targetbuf[len] = '\0';
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1 && errno != ENOENT)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
ret = TRUE;
}
else
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
int errsv = errno;
if (errsv != ENOENT)
{
- ot_util_set_error_from_errno (error, errsv);
+ gs_set_error_from_errno (error, errsv);
goto out;
}
}
int res = lsetfilecon (gs_file_get_path_cached (target), label);
if (res != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
src_fd = openat (src_parent_dfd, name, O_RDONLY | O_NOFOLLOW | O_NOCTTY | O_NOATIME | O_CLOEXEC);
if (src_fd == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
in = g_unix_input_stream_new (src_fd, TRUE);
stbuf->st_mode);
if (dest_fd == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
out = g_unix_output_stream_new (dest_fd, TRUE);
if (fchown (dest_fd, stbuf->st_uid, stbuf->st_gid) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fchmod (dest_fd, stbuf->st_mode) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fdatasync (dest_fd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
targetbuf[len] = '\0';
if (symlinkat (targetbuf, dest_parent_dfd, name) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fchownat (dest_parent_dfd, name,
stbuf->st_uid, stbuf->st_gid,
AT_SYMLINK_NOFOLLOW) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
if (fstat (src_dfd, &src_stbuf) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fchown (dest_dfd, src_stbuf.st_uid, src_stbuf.st_gid) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fchmod (dest_dfd, src_stbuf.st_mode) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
/* Create with mode 0700, we'll fchmod/fchown later */
if (mkdirat (dest_parent_dfd, name, 0700) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
srcd = fdopendir (src_dfd);
if (!srcd)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fstatat (src_dfd, name, &child_stbuf,
AT_SYMLINK_NOFOLLOW) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
/* And finally, fsync the fd */
if (fsync (dest_dfd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
else
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
g_prefix_error (error, "mkdirat: ");
goto out;
}
if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Failed to read modified config file '%s': ", path);
goto out;
}
dest_parent_dfd = dup (new_etc_fd);
if (dest_parent_dfd == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
;
else
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
{
if (unlinkat (new_etc_fd, path, 0) < 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
if (fsync (dest_parent_dfd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
int ret = ot_opendirat (dfd, path, follow);
if (ret == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
return FALSE;
}
*out_fd = ret;
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR));
if (G_UNLIKELY (bytes_read < 0))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
g_free (buf);
goto out;
}
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
return FALSE;
}
int r = posix_fallocate (fd, 0, g_bytes_get_size (contents));
if (r != 0)
{
- ot_util_set_error_from_errno (error, r);
+ gs_set_error_from_errno (error, r);
goto out;
}
}
if (fdatasync (fd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (renameat (parent_dfd, tmpname, parent_dfd, target_basename) == -1)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
if (fsync (dfd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
/* Ensure the link has hit disk */
if (fsync (parent_dfd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
/* And sync again for good measure */
if (fsync (parent_dfd) != 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
return ret;
}
-void
-ot_util_set_error_from_errno (GError **error,
- gint saved_errno)
-{
- g_set_error_literal (error,
- G_IO_ERROR,
- g_io_error_from_errno (saved_errno),
- g_strerror (saved_errno));
- errno = saved_errno;
-}
-
void
ot_util_fatal_literal (const char *msg)
{
gboolean ot_util_path_split_validate (const char *path, GPtrArray **out_components, GError **error);
-void ot_util_set_error_from_errno (GError **error, gint saved_errno);
-
G_END_DECLS
g_file_descriptor_based_get_fd (stream), start);
if (!map)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
goto out;
if (chmod (gs_file_get_path_cached (dir), 01777) < 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
{
if (symlink ("../run", gs_file_get_path_cached (dir)) < 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
{
if (symlink ("../run/lock", gs_file_get_path_cached (dir)) < 0)
{
- ot_util_set_error_from_errno (error, errno);
+ gs_set_error_from_errno (error, errno);
goto out;
}
}
int errsv = errno;
if (errsv != ENOSYS)
{
- ot_util_set_error_from_errno (error, errsv);
+ gs_set_error_from_errno (error, errsv);
goto out;
}
}